package eu.androidtraining.dashboard;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class Startseite extends Activity {
	
	private static final int UNTERACTIVITY_BEFRAGEN	= 1000;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_startseite);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_startseite, menu);
        return true;
    }
    
    public void wechsleActivity(final View view){
    	switch (view.getId()) {
		case R.id.sf_unteractivity:
			startActivity(new Intent(this, Unteractivity.class));
			break;
		case R.id.sf_unteractivity_mit_antwort:
			Intent intent = new Intent(this, UnteractivityMitAntwort.class);
			intent.putExtra("Frage", ((EditText) findViewById(R.id.ed_frage)).getText().toString());
			startActivityForResult(intent, UNTERACTIVITY_BEFRAGEN);
		default:
			break;
		}
    }

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if(resultCode == Activity.RESULT_OK && requestCode == UNTERACTIVITY_BEFRAGEN){
			Toast.makeText(this, "Die Antwort ist " + data.getExtras().getInt("Antwort"), Toast.LENGTH_SHORT).show();
		}
		super.onActivityResult(requestCode, resultCode, data);
	}
    
    
}
